import requests

from api import log
from config import HOST


class ApiRecharge:
    def __init__(self, session):
        # 获取session对象
        self.session = session
        # 充值验证码url
        self.__url_code = HOST + "/common/public/verifycode/{}"
        # 后台冲值url
        self.__url_recharge = HOST + "/trust/trust/recharge"

    # 充值验证码接口  封装
    def api_img_code(self,random):
        log.info("正在调用充值验证码接口，请求方法get，请求url:{}".format(self.__url_code.format(random)))
        # 调用get
        return self.session.get(url=self.__url_code.format(random))


    # 后台充值接口  封装
    def api_recharge(self):
        data = {
            "paymentType":"chinapnrTrust",
            "amount":10000,
            "formStr":"reForm",
            "valicode":"8888"
        }
        log.info("正在调用后台充值接口，请求方法post，请求url:{},请求参数:{}".format(self.__url_recharge,data))
        return self.session.post(self.__url_recharge, data)